package com.tianji.learning.controller;


import com.tianji.api.dto.leanring.LearningLessonDTO;
import com.tianji.api.dto.leanring.LearningRecordFormDTO;
import com.tianji.learning.service.ILearningRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 学习记录表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-11-24
 */
@RestController
@RequestMapping("/learning-records")
@Slf4j
@Api(tags = "学习记录管理")
@RequiredArgsConstructor
public class LearningRecordController {

    private final ILearningRecordService learningRecordService;

    /**
     * 查询指定课程学习记录
     * @param courseId
     * @return
     */
    @GetMapping("/course/{courseId}")
    @ApiOperation("查询指定课程学习记录")
    public LearningLessonDTO queryLearningRecordByCourse(@PathVariable("courseId") Long courseId){
        log.info("查询指定课程学习记录，课程id：{}", courseId);
        LearningLessonDTO learningRecords = learningRecordService.getLearningRecords(courseId);
        return learningRecords;
    }

    /**
     * 提交学习进度
     * @param learningRecordFormDTO
     */
    @PostMapping
    @ApiOperation("提交学习进度")
    public void submitStudyRecords(@RequestBody LearningRecordFormDTO learningRecordFormDTO){
        log.info("提交学习进度，实体类：{}", learningRecordFormDTO);
        learningRecordService.submitStudyRecords(learningRecordFormDTO);
    }



}
